﻿#ifndef CX_DEVICE_SDK_H
#define CX_DEVICE_SDK_H
#include "CxDefine.h"

//windows
#if (defined(_WIN32) || defined(_WIN64)) 
	#include <windows.h>
	#ifdef CXDEVICE_EXPORTS
		#define CX_DEVICE_API extern "C" __declspec(dllexport)
	#else
		#define CX_DEVICE_API extern "C" __declspec(dllimport)
	#endif    
	#define CALLBACK __stdcall
//linux
#elif defined(__linux__) || defined(__APPLE__)
	#define CALLBACK  
	#define CX_DEVICE_API extern "C"
	#ifdef __OBJC__
		#include "objc/objc.h"
	#endif
#else
	#error "Unsupported platform"
#endif

// sdk oprs
CX_DEVICE_API int32_t   CxDeviceSDKInit();
CX_DEVICE_API int32_t   CxDeviceSDKInitWithOption(CxSDKInitOptions options);
CX_DEVICE_API int32_t   CxDeviceSDKDeInit();
CX_DEVICE_API char*		CxDeviceGetErrorDesc(int32_t errorCode);
CX_DEVICE_API int32_t   CxDeviceGetCardInfoList(CardInfo** cardInfoList, int32_t* cardCount);

//card oprs
CX_DEVICE_API int32_t	CxDeviceOpenCard(CardInfo cardInfo, CxDeviceHandle* hDevice);
CX_DEVICE_API int32_t	CxDeviceCloseCard(CxDeviceHandle hDevice);
CX_DEVICE_API int32_t	CxDeviceInitCard(CxDeviceHandle hDevice);
CX_DEVICE_API int32_t	CxDeviceInitCardWithOption(CxDeviceHandle hDevice, CxCardInitOptions options);
CX_DEVICE_API int32_t	CxDeviceWriteCardConfig(CxDeviceHandle hDevice, uint32_t type, int32_t data);
CX_DEVICE_API int32_t	CxDeviceResetCard(CxDeviceHandle hDevice);
CX_DEVICE_API int32_t	CxDeviceDeinitCard(CxDeviceHandle hDevice);
CX_DEVICE_API int32_t	CxDeviceEnableCard(CxDeviceHandle hDevice);
CX_DEVICE_API int32_t	CxDeviceDisableCard(CxDeviceHandle hDevice);
CX_DEVICE_API int32_t	CxDeviceSendCardSoftwareTrigger(CxDeviceHandle hDevice);
CX_DEVICE_API int32_t	CxDeviceWriteCardRawData(CxDeviceHandle hDevice, char* userDefineBuffer,
	uint32_t writeLen, uint32_t* actualWriteLen, int32_t timeout);
CX_DEVICE_API int32_t	CxDeviceReadCardRawData(CxDeviceHandle hDevice, char* userDefineBuffer,
	uint32_t wantLen, uint32_t* actualWriteLen, int32_t timeout);
CX_DEVICE_API int32_t	CxDeviceReadCardRawDataOffset(CxDeviceHandle hDevice, char* userDefineBuffer, uint32_t offset,
	uint32_t wantLen, uint32_t* actualReadLen, int32_t timeout);
CX_DEVICE_API int32_t   CxDeviceReadCardFrames(CxDeviceHandle hDevice, SciAcqPackage** frames, uint32_t* frameCount);//TODO：待实现
CX_DEVICE_API int32_t	CxDeviceWriteReg(CxDeviceHandle hDevice, uint32_t addr, uint32_t data);
CX_DEVICE_API int32_t	CxDeviceReadReg(CxDeviceHandle hDevice, uint32_t addr, uint32_t* data);
CX_DEVICE_API int32_t	CxDeviceStartSaveCardData(CxDeviceHandle hDevice, const char* fileName);
CX_DEVICE_API int32_t	CxDeviceStopSaveCardData(CxDeviceHandle hDevice);

// channel oprs
CX_DEVICE_API int32_t	CxDeviceWriteChannelConfig(CxDeviceHandle hDevice, int32_t chNo, uint32_t type, int32_t data);
CX_DEVICE_API int32_t	CxDeviceEnableChannel(CxDeviceHandle hDevice, int32_t chNo);
CX_DEVICE_API int32_t	CxDeviceDisableChannel(CxDeviceHandle hDevice, int32_t chNo);
CX_DEVICE_API int32_t	CxDeviceSendChannelSoftwareTrigger(CxDeviceHandle hDevice, int32_t chNo);
CX_DEVICE_API int32_t	CxDeviceWriteChannelRawData(CxDeviceHandle hDevice, int32_t chNo, char* userDefineBuffer,
	uint32_t writeLen, uint32_t* actualWriteLen, int32_t timeout);
CX_DEVICE_API int32_t	CxDeviceReadChannelRawData(CxDeviceHandle hDevice, int32_t chNo, char* userDefineBuffer,
	uint32_t wantLen, uint32_t* actualReadLen, int32_t timeout);
CX_DEVICE_API int32_t	CxDeviceReadChannelRawDataOffset(CxDeviceHandle hDevice, int32_t chNo, char* userDefineBuffer,
	uint32_t offset, uint32_t wantLen, uint32_t* actualReadLen, int32_t timeout);
CX_DEVICE_API int32_t   CxDeviceReadChannelFrames(CxDeviceHandle hDevice, int32_t chNo, SciAcqPackage** frames, uint32_t* frameCount);
CX_DEVICE_API int32_t	CxDeviceSetChannelRecvCallback(CxDeviceHandle hDevice, int32_t chNo, OnePackComeCallback packCome);
CX_DEVICE_API int32_t	CxDeviceStartChannelRecv(CxDeviceHandle hDevice, int32_t chNo);
CX_DEVICE_API int32_t	CxDeviceStopChannelRecv(CxDeviceHandle hDevice, int32_t chNo);
CX_DEVICE_API int32_t	CxDeviceStartSaveChannelData(CxDeviceHandle hDevice, int32_t chNo, const char* fileName, uint32_t bufSize);
CX_DEVICE_API int32_t	CxDeviceStopSaveChannelData(CxDeviceHandle hDevice, int32_t chNo);
#endif
